import request from '@/config/axios'

export interface TaskVO {
  id: number
  name: string
  no: string
  type: number
  waitTime: number
  status: number
  startTime: Date
  endTime: Date
  progress: number
  numberCount: number
  callCount: number
}

// 查询外呼任务列表
export const getTaskPage = async (params) => {
  return await request.get({ url: `/call/task/page`, params })
}

// 查询外呼任务详情
export const getTask = async (id: number) => {
  return await request.get({ url: `/call/task/get?id=` + id })
}

// 新增外呼任务
export const createTask = async (data: TaskVO) => {
  return await request.post({ url: `/call/task/create`, data })
}

// 修改外呼任务
export const updateTask = async (data: TaskVO) => {
  return await request.put({ url: `/call/task/update`, data })
}

// 删除外呼任务
export const deleteTask = async (id: number) => {
  return await request.delete({ url: `/call/task/delete?id=` + id })
}

// 导出外呼任务 Excel
export const exportTask = async (params) => {
  return await request.download({ url: `/call/task/export-excel`, params })
}

// 获取任务列表
export const getTaskList = async () => {
  return await request.get({ url: `/call/task/simple-list` })
}

// 添加任务
export const addTaskNumber = async (data) => {
  return await request.post({ url: `/call/task-number/create`, data })
}

// 任务启停
export const controlTask = async (data) => {
  return await request.post({ url: `/call/task/control`, data })
}

// 任务详情获取绑定号码
export const getTaskNumber = async (params) => {
  return await request.get({ url: `/call/task-number/page`, params })
}

// 批量添加任务
export const addTaskNumberBatch = async (data) => {
  return await request.post({ url: `/call/task-number/batch-create`, data })
}

// 获得呼叫中心语音文件分页
export const getVoiceFilePage = async (params) => {
  return await request.get({ url: `/call/voice-file/page`, params })
}
// 创建呼叫中心语音文件
export const createVoiceFile = async (formData) => {
  return await request.upload({ url: `/call/voice-file/create`, data: formData })
}
// 删除呼叫中心语音文件
export const deleteVoiceFile = async (id: number) => {
  return await request.delete({ url: `/call/voice-file/delete?id=` + id })
}
// 语音文件详情
export const getVoiceFileId = async (id) => {
  return await request.get({ url: `/call/voice-file/get?id=${id}` })
}

// 追加外呼号码-单个
export const appendOne = async (formData) => {
  return await request.upload({ url: `/call/task/append`, data: formData })
}
//追加外呼号码-导入文件
export const appendFile = async (formData) => {
  return await request.upload({ url: `/call/task/append-by-file`, data: formData })
}
//追加外呼号码-从呼叫名单
export const appendCalle = async (formData) => {
  return await request.upload({ url: `/call/task/append-by-callee-list`, data: formData })
}

// 编辑外呼任务的并发模式
export const editTaskConCurr = async (data) => {
  return await request.put({ url: `/call/task/update`, data })
}

// 任务重呼
export const callRecall = async (data) => {
  return await request.post({ url: `/call/task/recall`, data })
}

// 结果类型统计
export const getCountTask = async (id) => {
  return await request.get({ url: `/call/workbench/count-result-type-by-task-id?taskId=${id}` })
}
// 话单状态统计
export const getCountCodeTask = async (id) => {
  return await request.get({ url: `/call/workbench/count-result-code-by-task-id?taskId=${id}` })
}
// tts音色
export const ttsTimbre = async (id) => {
  return await request.get({ url: `/call/timbre/simple-list` })
}
